1. Field
This disclosure relates generally to processor systems, and more specifically but not exclusively, to methods and apparatus for arithmetic operations performed by processors.
2. Description
Decimal floating-point additions are typically implemented in software because there is no specialized hardware for decimal floating-point additions in most modern processors. A floating-point number (D) is normally represented by a coefficient (C) and an exponent (E), i.e., D=C·10^E, where both C and E are decimal integers. The precision of such a representation may be determined by the number of decimal digits in C, with more decimal digits in C resulting in more precise representation of D. Assume that coefficients and exponents of decimal floating-point numbers are stored in a binary format in a computer. A typical process for calculating an addition between two decimal floating-point numbers (e.g., D1=C1·10^E1, and D2=C2·10^E2) is as follows: convert coefficients (C1 and C2) and exponents (E1 and E2) from binary to decimal; perform a decimal integer addition between C1·10^(E1−E2) (assume that E1>=E2) and C2; round exact decimal addition result correctly to the destination precision; and then convert the coefficient and exponent of the final results from decimal back to binary.
Although it would be possible to store coefficients and exponents of decimal floating-point numbers in a decimal format (e.g., Binary-Coded Decimal (BCD) format) all the time, then the advantage offered by existing instructions or circuitry that operate on binary numbers could not be taken of directly. In the above process for decimal floating-point addition, conversion back and forth between decimal and binary formats and decimal integer addition consume a number of clock cycles. More importantly, the rounding operation for the addition result, which typically uses remainder-based calculation, is very expensive in terms of clock cycles. Thus, it is desirable to have faster approaches for decimal floating-point additions so that the overall performance of a computing system can be improved.